//
//  MCGetMerchantInfoModel.m
//  TLYL
//
//  Created by miaocai on 2017/7/26.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCGetMerchantInfoModel.h"



@interface MCGetMerchantInfoModel ()


@end


@implementation MCGetMerchantInfoModel

singleton_m(MCGetMerchantInfoModel)




- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"web-api/api/v4/get_merchant_info";
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    
    NSString *timeString = [NSString getCurrentTimestamp];
    NSString *jsonStr = @"{}";
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",jsonStr,[[NSUserDefaults standardUserDefaults] objectForKey:@"token"],timeString];
    return @{@"params":jsonStr,
             @"sign":[sign MD5],
             @"timestamp":timeString
             };
    
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
    
    if (manager.ResponseRawData[@"MaxRebate"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"MaxRebate"] forKey:MerchantMaxRebate];
    }
    if (manager.ResponseRawData[@"MinRebate"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"MinRebate"] forKey:MerchantMinRebate];
    }
    if (manager.ResponseRawData[@"Mode"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"Mode"] forKey:MerchantMode];
    }
    if (manager.ResponseRawData[@"XRebate"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"XRebate"] forKey:MerchantXRebate];
    }
    if (manager.ResponseRawData[@"Red_Envelopes_IsOpen"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"Red_Envelopes_IsOpen"] forKey:MCRed_Envelopes_IsOpen];
    }
    
    if (manager.ResponseRawData[@"Proxy_Level"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"Proxy_Level"] forKey:MCProxy_Level];
    }
    if (manager.ResponseRawData[@"Rebate"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"Rebate"] forKey:MCRebate];
    }
    if (manager.ResponseRawData[@"IsRegisterSub"]) {
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"IsRegisterSub"] forKey:MCIsRegisterSub];
    }
    //    "HandRebate": "1952", 手动开户代理
    //    "HandQRebate": 1948,手动开户会员
    //    "QARebate": "1946",链接开户代理
    //    "QRebate": 1950,链接开户会员
    if (manager.ResponseRawData[@"QARebate"]) { //链接开户代理
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"QARebate"] forKey:MCQARebate];
    }
    if (manager.ResponseRawData[@"HandRebate"]) {// 手动开户代理
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"HandRebate"] forKey:MCHandRebate];
    }
    if (manager.ResponseRawData[@"QRebate"]) { // 链接开户会员
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"QRebate"] forKey:MCQRebate];
    }
    if (manager.ResponseRawData[@"HandQRebate"]) {// 手动开户会员
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"HandQRebate"] forKey:MCHandQRebate];
    }
    if (manager.ResponseRawData[@"IsChaseNumber"]) {// 1,是否允许追号 0 bu 1 shi
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"IsChaseNumber"] forKey:MCIsChaseNumber];
    }
    
    if (manager.ResponseRawData[@"MinBetMoney"]) {// 最小投注额度
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"MinBetMoney"] forKey:MCMinBetMoney];
    }
    
    if (manager.ResponseRawData[@"MaxBetMultiple"]) {// 最大投注倍数
        [[NSUserDefaults standardUserDefaults] setObject:manager.ResponseRawData[@"MaxBetMultiple"] forKey:MCMaxBetMultiple];
    }
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager.ResponseRawData);
    }
}




-(void)clearData{
   
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MerchantMaxRebate];

    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MerchantMinRebate];

    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MerchantMode];
    
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MerchantXRebate];

}
@end
